package com.songkun.template.ui.base;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.songkun.template.R;
import com.songkun.template.databinding.ActivityBaseBinding;


/**
 * @描述: 普通的Activity
 * @项目名: AndroidTemplate
 * @包名: com.songkun.template.ui.base
 * @类名:
 * @作者: soongkun
 * @创建时间: 2016/4/29 13:16
 */

public abstract class CommonActivity extends BaseActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mBasebinding = DataBindingUtil.setContentView(this, R.layout.activity_base);

        setSupportActionBar(mBasebinding.toolbar);

        initHeader();
        initContentView();
        initData();
    }


    @Override
    public void setContentView(View view) {
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup
                .LayoutParams.MATCH_PARENT);
        mBasebinding.container.addView(view, lp);
    }


    public ActivityBaseBinding getActivityBaseViewBinding() {
        return mBasebinding;
    }


    /**
     * 是否隐藏Title布局
     *
     * @param isShow
     */
    public void isTitleLayoutShow(boolean isShow) {
        mBasebinding.toolbar.setVisibility(isShow ? View.VISIBLE : View.GONE);
    }


    /**
     * 初始化通用title
     */
    protected abstract void initHeader();

    /**
     * 添加内容布局视图
     */
    protected abstract void initContentView();

    /**
     * 初始化数据
     */
    protected abstract void initData();
}
